<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        *{
            padding: 0px;
            margin:0px;
        }
        .d1{
            width:500px;
            height: 500px;
            border:1px solid red;
            margin-left: 200px;
            position: relative;
        }
        .d2{
            width:300px;
            height: 300px;
            border:1px solid green;
            margin-left:100px;
            position: absolute;
        }
        .d3{
            width:100px;
            height: 100px;
            border:1px solid blue;

            /*
                如果祖先元素是非static定位，此时绝对定位参考物就是离自己最近的非static定位的祖先标签
                如果祖先元素是static定位，此时参考物就是浏览器窗口
                一般情况下:我们都会给父元素设置非static定位，一般给父元素设置relative较多
            */

            position: absolute;
            top:20px;
            left:40px;
        }


    </style>
</head>
<body>
<div class="d1">
    <div class="d2">
        <div class="d3"></div>
    </div>
</div>
</body>
</html>